var ns;
var app = new Vue({
    el: '#app',
    data: {
        form: {
            username: '',
            verifycode: ''
        },
    },
    methods: {
        getValidateCode: function() {

          var that = this;
          if (that.form.username == '') {
              api.toast({
                  msg: '请输入手机号码',
                  duration: 2000,
                  location: 'bottom'
              });
              return;
          }
          var opt = {
              action: 'registercheckphone',
              Username: that.form.username,
              openid: '',
              type: '',
              UserType: 'APPBusiness',
              OperationType:2
          };
          ns.post(opt, function(succeed, data, err) {
                if (succeed) {
                  //alert(JSON.stringify(data));
                    //成功
                    api.toast({
                        msg: '获取验证码成功！',
                        duration: 2000,
                        location: 'bottom'
                    });
                } else if (err) {
                    api.toast({
                        msg: err,
                        duration: 2000,
                        location: 'bottom'
                    });
                }
            })
        },
        open_editpassword: function() {
          var that = this;
               //判断验证码是否成功
               if (that.form.username == '') {
                   api.toast({
                       msg: '请输入手机号码',
                       duration: 2000,
                       location: 'bottom'
                   });
                   return;
               }
               if (that.form.verifycode == '') {
                   api.toast({
                       msg: '请输入验证码',
                       duration: 2000,
                       location: 'bottom'
                   });
                   return;
               }
               var opt = {
                   action: 'completeregister',
                   Username: that.form.username,
                   verifycode: that.form.verifycode,
               };
               ns.post(opt, function(succeed, data, err) {
                   if (succeed) {
                       //成功，跳转到下一步
                       ns.openWin('dl_forget_passwordnext', '密码重置', {
                           id: that.form.username,
                           passwordtype:1,
                       });
                   } else if (err) {
                       api.toast({
                           msg: err,
                           duration: 2000,
                           location: 'bottom'
                       });
                   }
               });
        }
    }
});
apiready = function() {
    api.parseTapmode();
    ns = window.Foresight.Util;
};
